#include<bits/stdc++.h>
#define N 100005
using namespace std;
const double eps=1e-5;
int T,n,m,L,V,tot,ans;
bool vis[N];
double p[N],d[N],v[N],a[N];
struct node{
    double l,r;
}car[N];
struct query{
    int l,r;
}rec[N];
bool cmp(query x,query y){
    return x.r<y.r;
}
void Init(){
    tot=0,ans=0;
    memset(vis,0,sizeof vis);
}
void calc(int d,int v,int a,int id){
    if(a==0){
        if(v>V){
            car[id]={d,L};
            return;
        }
        else{
            car[id]={-1,-1};
            return;
        }
    }
    else if(a>0){
        if(v>V){
            car[id]={d,L};
            return;
        }
        else if(v==V){
            car[id]={d+eps,L};
            return;
        }
        else{
            double x=(V*V-v*v)*1.0/(2*a);
            double st=d+x;
            if(st<=L){
                car[id]={st+eps,L};
                return;
            }
            else{
                car[id]={-1,-1};
                return;
            }
        }
    }
    else{
        if(v<=V){
            car[id]={-1,-1};
            return;
        }
        else{
            double x=(V*V-v*v)*1.0/(2*a);
            double st=d+x;
            if(st<=L){
                car[id]={d,st-eps};
                return;
            }
            else{
                car[id]={d,L};
                return;
            }
        }
    }
}
void solve(){
    sort(rec+1,rec+tot+1,cmp);
    for(int i=2;i<=tot;i++){
        if(rec[i].l<=rec[1].l) vis[i]=1;
    }
    for(int ll=1,rr=1;ll<=tot;ll++){
        if(vis[ll]) continue;
        while(rr<=tot&&(vis[rr]||rec[rr].l<=rec[ll].r)) vis[rr]=1,rr++;
        ans++;
    }
    cout<<m-ans<<"\n";
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        Init();
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++) cin>>p[i];
        for(int i=1;i<=n;i++){
            calc(d[i],v[i],a[i],i);
        }
        for(int i=1;i<=n;i++){
            if(car[i].l<0&&car[i].r<0) continue;
            int ll=lower_bound(p+1,p+m+1,car[i].l)-p;
            if(p[ll]<=car[i].r&&ll<=m){
                tot++;
                rec[tot].l=ll;
                rec[tot].r=upper_bound(p+1,p+m+1,car[i].r)-p-1;
            }
        }
        cout<<tot<<" ";
        solve();
    }
    return 0;
}
